package com.czp;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import entity.Contact_person;

public class orderFormSevice {
	private orderFormDao dao = new orderFormDao();
	// 联系人存储Contact_person
	public Long saveContact(String contactName, String phone3, String email, String weixing) {
		return dao.saveContact(contactName,phone3,email,weixing);
	}
	// 存储旅客信息
	public int saveCustomer(String firstname, String lastname, String sex, String birthDay, String iDtype,
			String idcard, String phone, int person_id) {
		return dao.saveCustomer(firstname,lastname,sex,birthDay,iDtype,idcard,phone,person_id);
	}
	// 两个日期相差天数
	
	/**
     * date2比date1多的天数
     * @param date1    
     * @param date2
     * @return    
     */
	 public long dayDiff(String date1, String date2,String format) {
	        if (null == date1 || null == date2) {
	            return -1;
	        }
	        SimpleDateFormat formater = new SimpleDateFormat(format);
	 
	        long diff = 0;
	            long d1;
				try {
					d1 = formater.parse(date1).getTime();
					long d2 = formater.parse(date2).getTime();
					diff=(d2-d1)/(1000 * 60 * 60 * 24);
				} catch (ParseException e) {
					e.printStackTrace();
				}
	        return diff;
	 }
	 
	// price 保存
	public Long savePrice(String startDate, String endDate, int day_number, int night_day, double price_day,
			int buy_number, int bed_number, String sum_price, int person_id,int hotel_id) {
		return dao.savePrice(startDate,endDate,day_number,night_day,price_day,buy_number,bed_number,sum_price,person_id,hotel_id);
		
	}
	
	// 根据联系人name 插叙 person对象
	public Contact_person queryContact(String contactName) {
		return dao.queryContact(contactName);
	}
			
}
